package com.ebraga.trackerclub.android.util;

import android.app.ProgressDialog;
import android.content.Context;

public class SmartServiceJavascriptInterface {
	Context context;
	ProgressDialog ringProgressDialog;
	
	public SmartServiceJavascriptInterface(Context c) {
		this.context = c;
	}

	public void showMessage(String message) {
		
		UtilView.showMessage(context, message);
		
	}
	

	public void showWaitMessage(String time) {
		showWaitMessage(new Long(time));
	}	
	
	public void showWaitMessage() {
		showWaitMessage(5000l);
	}
	
	private void showWaitMessage(final long time) {
		
		try{
			String wait 	= UtilView.getTextMessage(context, ISmartServiceConstants.WARN_CODE.WARN_WAITTING);
			String proccess = UtilView.getTextMessage(context, ISmartServiceConstants.WARN_CODE.WARN_INPROCESS);
			
			ringProgressDialog = ProgressDialog.show(context, wait, proccess, true);

			ringProgressDialog.setCancelable(true);

			new Thread(new Runnable() {
				@Override
				public void run() {
					try {
						// Here you should write your time consuming task...
						// Let the progress ring for 10 seconds...
						Thread.sleep(time);
					} catch (Exception e) {

					}
					ringProgressDialog.dismiss();
				}
			}).start();


		} catch (Exception e) {
			DLog.d(e.getMessage());
		}		
		
	}
	
	public void hideWaitMessage() {
		try{
			ringProgressDialog.dismiss();
		} catch (Exception e) {
			DLog.d(e.getMessage());
		}			 
	}	
	
		
	
}
